import Vue from 'vue'
import VueRouter from 'vue-router'
import Password from '@/views/password/Password.vue'
import NotFound from '@/components/NotFound'

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return routerPush.call(this, location).catch(error => error)
}

Vue.use(VueRouter)

// route level code-splitting
// this generates a separate chunk (chunkName.[hash].js) for this route
// which is lazy-loaded when the route is visited.

// const ForgetPassword = () =>
// import(/* webpackChunkName: "ForgetPassword" */ '@/views/password/ForgetPassword.vue')
const PaySlipContent = () =>
	import(/* webpackChunkName: "PaySlipContent" */ '@/views/pay-slip/PaySlipContent.vue')
// const PaySlipHistory = () =>
// 	import(/* webpackChunkName: "PaySlipHistory" */ '@/views/pay-slip-history/PaySlipHistory.vue')

const routes = [
	{
		path: '*',
		component: NotFound,
		name: 'Notfound',
		meta: {
			title: '404'
		}
	},
	{
		path: '/',
		redirect: '/paySlipContent'
	},
	// {
	// 	path: '/password',
	// 	name: 'Password',
	// 	component: Password,
	// 	meta: {
	// 		title: '输入密码'
	// 	}
	// },
	// {
	// 	path: '/forgetPassword',
	// 	name: 'ForgetPassword',
	// 	component: ForgetPassword,
	// 	meta: {
	// 		title: '忘记密码'
	// 	}
	// },
	{
		path: '/paySlipContent',
		name: 'PaySlipContent',
		component: PaySlipContent,
		meta: {
			title: '查看工资条'
		}
	}
	// {
	// 	path: '/paySlipHistory',
	// 	name: 'PaySlipHistory',
	// 	component: PaySlipHistory,
	// 	meta: {
	// 		title: '工资条历史'
	// 	}
	// }
]

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

export default router
